<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Copilot 配置指南</title>
    <style>
        :root {
            --primary-color: #0066CC;
            --background-light: #ffffff;
            --text-color: #1d1d1f;
            --code-background: #f5f7fa;
            --border-color: #d2d2d7;
            --warning-background: #fff7ed;
            --warning-border: #fec589;
            --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        }

        body {
            font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'SF Pro Icons', 'Helvetica Neue', sans-serif;
            line-height: 1.6;
            color: var(--text-color);
            max-width: 800px;
            margin: 0 auto;
            padding: 2rem;
            background-color: var(--background-light);
        }

        h1 {
            font-size: 2.5rem;
            font-weight: 600;
            margin-bottom: 2rem;
            color: var(--text-color);
        }

        h2 {
            font-size: 1.5rem;
            font-weight: 600;
            margin-top: 3rem;
            margin-bottom: 1rem;
            color: var(--text-color);
        }

        .step {
            margin-bottom: 1rem;
            padding-left: 1.5rem;
            position: relative;
        }

        .step::before {
            content: "";
            position: absolute;
            left: 0;
            top: 0.5rem;
            width: 6px;
            height: 6px;
            border-radius: 50%;
            background-color: var(--primary-color);
        }

        .step a {
            color: var(--primary-color);
            text-decoration: none;
            transition: var(--transition);
        }

        pre {
            background-color: var(--code-background);
            border-radius: 12px;
            padding: 1.5rem;
            overflow-x: auto;
            margin: 1.5rem 0;
            font-family: 'SF Mono', Monaco, Consolas, monospace;
            font-size: 0.9rem;
            line-height: 1.5;
        }

        code {
            font-family: 'SF Mono', Monaco, Consolas, monospace;
            background-color: var(--code-background);
            padding: 0.2rem 0.4rem;
            border-radius: 4px;
            font-size: 0.9em;
        }

        .warning {
            background-color: var(--warning-background);
            border: 1px solid var(--warning-border);
            border-radius: 12px;
            padding: 1rem 1.5rem;
            margin: 1.5rem 0;
            font-size: 0.95rem;
        }

        .warning::before {
            content: "🚨";
            margin-right: 0.5rem;
        }

        .note {
            background-color: var(--code-background);
            border: 1px solid var(--border-color);
            border-radius: 12px;
            padding: 1rem 1.5rem;
            margin: 1.5rem 0;
            font-size: 0.95rem;
        }

        .note::before {
            content: "🚧";
            margin-right: 0.5rem;
        }

        @media (prefers-color-scheme: dark) {
            :root {
                --background-light: #1d1d1f;
                --text-color: #f5f5f7;
                --code-background: #2c2c2e;
                --border-color: #3a3a3c;
                --warning-background: #3a3123;
                --warning-border: #8b5e34;
            }
        }

        @media (max-width: 768px) {
            body {
                padding: 1rem;
            }

            h1 {
                font-size: 2rem;
            }

            pre {
                padding: 1rem;
            }
        }

        .config-wrapper {
            position: relative;
        }

        .copy-button {
            position: absolute;
            top: 1rem;
            right: 1rem;
            padding: 0.5rem 1rem;
            background-color: var(--primary-color);
            color: white;
            border: none;
            border-radius: 6px;
            font-size: 0.9rem;
            cursor: pointer;
            transition: var(--transition);
        }

        .copy-button:hover {
            background-color: var(--hover-color);
        }

        .dynamic-domain {
            color: var(--primary-color);
            font-weight: 500;
        }

        #show-hb {
            display: none;
        }

        #hidden-hb {
            display: block;
        }

        .footer {
            display: flex;
            justify-content: center;
            align-items: center;
            margin-top: 32px;
            font-size: 13px;
            color: #86868b;
        }

        .footer a {
            color: var(--primary-color);
            text-decoration: none;
            transition: var(--transition);
        }

        .footer a:hover {
            text-decoration: underline;
        }
    </style>
</head>
<body>
<h1>Copilot 配置指南</h1>

<h2>VSCode</h2>
<div class="step">安装插件: <code>GitHub Copilot</code></div>
<div class="step">修改 VSCode 的 settings.json 文件, 添加以下配置:</div>
<div class="config-wrapper">
        <pre id="configCode">{
    "github.copilot.advanced": {
        "authProvider": "github-enterprise",
        "debug.overrideCAPIUrl": "https://api.<span class="dynamic-domain">loading...</span>",
        "debug.overrideProxyUrl": "https://copilot-proxy.<span class="dynamic-domain">loading...</span>",
        "debug.chatOverrideProxyUrl": "https://api.<span class="dynamic-domain">loading...</span>/chat/completions",
        "debug.overrideFastRewriteEngine": "v1/engines/copilot-centralus-h100",
        "debug.overrideFastRewriteUrl": "https://api.<span class="dynamic-domain">loading...</span>"
    },
    "github-enterprise.uri": "https://<span class="dynamic-domain">loading...</span>"
}</pre>
    <button id="copyBtn" class="copy-button">复制配置</button>
</div>

<h2>Jetbrains IDE系列</h2>
<div class="step">找到<code>设置</code> > <code>语言与框架</code> > <code>GitHub Copilot</code> > <code>Authentication
    Provider</code></div>
<div class="step">填写的值为: <code><span class="dynamic-domain">loading...</span></code></div>

<h2>Visual Studio 2022</h2>
<div class="step">更新到最新版本（内置 Copilot 版本）至少是 <code>17.10.x</code> 以上</div>
<div class="step">首先, 开启 Github Enterprise 账户支持：工具->环境->账户->勾选 <code>包含 Github Enterprise 服务器账户</code></div>
<div class="step">然后, 重启你的 <code>Visual Studio 2022</code> 编辑器</div>
<div class="step">最后, 点击添加 Github 账户，切换到 Github Enterprise 选项卡，输入 <code>https://<span
        class="dynamic-domain">loading...</span></code> 即可。
</div>

<h2>HBuilderX</h2>
<div id="show-hb">
    <div class="step">点击下载 <code><a href="https://pan.quark.cn/s/70e6849970e5" target="_blank">copilot-for-hbuilderx-v1.zip</a></code>
        插件到本地
    </div>
    <div class="step">将插件安装到 plugin目录下, 具体教程参考: <code><a
            href="https://hx.dcloud.net.cn/Tutorial/OfflineInstall" target="_blank">离线插件安装指南</a></code></div>
    <div class="step">重启 Hbuilder X 后点击登录 <code>GitHub Copilot</code> 即可.</div>
</div>

<div id="hidden-hb" class="warning">
    当前部署方式不支持 HBuilderX
</div>

<div class="footer">
    © 2024 Open Source Contributors
</div>
<script>
    document.addEventListener('DOMContentLoaded', function () {
        // 获取当前域名和端口
        const currentHost = window.location.host; // 这将获取 "domain:port" 格式

        // 只要是默认本地部署的域名，就显示 HBuilderX 的安装步骤
        if (currentHost.includes('copilot.supercopilot.top')) {
            document.getElementById('show-hb').style.display = 'block';
            document.getElementById('hidden-hb').style.display = 'none';
        } else {
            document.getElementById('show-hb').style.display = 'none';
            document.getElementById('hidden-hb').style.display = 'block';
        }

        // 更新所有需要替换的地方
        const domainElements = document.querySelectorAll('.dynamic-domain');
        domainElements.forEach(element => {
            element.textContent = currentHost;
        });
    });

    document.getElementById('copyBtn').addEventListener('click', function () {
        const configText = document.getElementById('configCode').textContent;
        navigator.clipboard.writeText(configText).then(() => {
            const originalText = this.textContent;
            this.textContent = '已复制！';
            setTimeout(() => {
                this.textContent = originalText;
            }, 2000);
        });
    });
</script>
</body>
</html>